package com.example.qa_back.service;

import com.example.qa_back.mapper.AdminMapper;
import org.springframework.stereotype.Service;

/**
 * @author 董帅
 * @date 2021/3/6 - 17:26
 */
@Service
public class AdminService {
    private final AdminMapper adminMapper;

    public AdminService(AdminMapper adminMapper) {
        this.adminMapper = adminMapper;
    }

    /*
    * 功能：判断前端输入的用户名是否存在
    * param：name，用户名
    * return：-1，不存在；id，存在
    * */
    public Integer judgeNameExist(String name) {
        Integer idByName = adminMapper.getIdByName(name);
        if (idByName == null) {
            return -1;
        } else {
            return idByName;
        }
    }
    /*
    * 功能：根据用户id得到密码
    * param：id，用户id
    * return：密码
    * */
    public String getPasswordById(Integer id) {
        return adminMapper.getPasswordById(id);
    }
}
